<template>
	<div id="audioClaims">
		<h1>审核订单</h1>
		<div class="wrapper">
			<ul>
				<li>订单编号：{{ claimsData._id }}</li>
				<li>所属订单：</li>
				<li>事故时间：{{ claimsData.accidentTime }}</li>
				<li>理赔申请时间：{{ claimsData.applyTime }}</li>
				<li>
					理赔图片：
					<img
						alt=""
						width="100px"
						height="100px"
						v-for="item in claimsData.images"
						:key="item"
						:src="'http://localhost:3000/images/' + item"
					/>
				</li>
				<li>
					<el-button
						:plain="true"
						type="primary"
						@click="audioClaimsSuccess"
						>审核通过</el-button
					>
					<el-button
						:plain="true"
						type="success"
						@click="audioClaimsFail"
						>审核不通过</el-button
					>
				</li>
			</ul>
		</div>
	</div>
</template>

<script>
import apis from "../../http/apis";
export default {
	mounted() {
		this.setClaims();
	},
	data() {
		return {
			claimsData: {},
		};
	},
	methods: {
		async setClaims() {
			const { data } = await apis.claims.getClaimsById({
				_id: this.$route.params._id,
			});
			this.claimsData = data.data[0];
			console.log(this.claimsData);
		},
		//审核成功
		async audioClaimsSuccess() {
			const { data } = await apis.claims.changeClaims([
				this.claimsData,
				{ state: 2, handleTime: new Date().toLocaleString() },
			]);
			if (data.code) {
				this.$message({
					message: "操作成功",
					type: "success",
				});
				// this.$router.push("/adminsSystem/claimsList");
			}
		},
		//审核失败
		async audioClaimsFail() {
			const { data } = await apis.claims.changeClaims([
				this.claimsData,
				{ state: 3, handleTime: new Date().toLocaleString() },
			]);
			if (data.code) {
				this.$message({
					message: "操作成功",
					type: "success",
				});
				// this.$router.push("/adminsSystem/claimsList");
			}
		},
	},
};
</script>

<style lang="scss">
#audioClaims {
	.wrapper {
		width: 800px;
		height: 400px;
		border-radius: 10px;
		margin: 0 auto;
		margin-top: 20px;
		padding: 20px 0;
		text-align: left;
		background-color: #fff;
		ul {
			margin-left: 100px;
			li {
				list-style: none;
				// height: 50px;
				line-height: 50px;
			}
		}
	}
}
</style>
